package com.ruoyi.dingtalk.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.proxy.HibernateProxy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

/**
 * 钉钉部门信息
 *
 * @author xueyu
 */
@ApiModel(value = "钉钉部门")
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@AllArgsConstructor
@TableName(value = "dd_dept")
@Entity
@Table(name = "dd_dept")
public class DdDept extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 3713134804736333233L;

    /**
     * 钉钉部门id 主键
     */
    @ApiModelProperty(value = "主键")
    @Id
    @Column(name = "dept_id")
    @TableId(value = "dept_id", type = IdType.NONE)
    private Long deptId;


    /**
     * 系统部门id
     */
    @ApiModelProperty(value = "系统部门id")
    @Column(name = "sys_dept_id")
    @TableField(value = "sys_dept_id")
    private Long sysDeptId;

    /**
     * 名称
     */
    @ApiModelProperty(value = "名称")
    @Column(name = "dept_name")
    @TableField(value = "dept_name")
    private String deptName;

    /**
     * 钉钉父部门id
     */
    @ApiModelProperty(value = "钉钉父部门id")
    @Column(name = "parent_id")
    @TableField(value = "parent_id")
    private Long parentId;

    /**
     * 在父部门中的次序
     */
    @ApiModelProperty(value = "部门次序")
    @Column(name = "order_in_parent")
    @TableField(value = "order_in_parent")
    private Long orderInParent;

    /**
     * 部门主管的钉钉userid列表
     */
    @ApiModelProperty(value = "部门主管的钉钉userid列表")
    @Column(name = "dept_manager_user_ids")
    @TableField(value = "dept_manager_user_ids")
    private String deptManagerUserIds;

    /**
     * 钉钉部门的企业id
     */
    @ApiModelProperty(value = "钉钉部门的企业id")
    @Column(name = "dd_corp_id")
    @TableField(value = "dd_corp_id")
    private String ddCorpId;

    @Override
    public final boolean equals(Object o) {
        if (this == o) return true;
        if (o == null) return false;
        Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
        Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
        if (thisEffectiveClass != oEffectiveClass) return false;
        DdDept ddDept = (DdDept) o;
        return getDeptId() != null && Objects.equals(getDeptId(), ddDept.getDeptId());
    }

    @Override
    public final int hashCode() {
        return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
    }
}
